package com.yonyou.pmclouds.stagecheck.service.rmiimpl;

import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.ref.itf.RefCodeConst;
import com.yonyou.pmclouds.basecom.ref.itf.ReferenceCheckOfBusiness;
import com.yonyou.pmclouds.basecom.util.BeanHelper;
import com.yonyou.pmclouds.stagecheck.entity.StageCheckVO;
import com.yonyou.pmclouds.stagecheck.rmitf.StageCheckQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ReferenceCheckOfStageCheck implements ReferenceCheckOfBusiness{
    @Autowired
    private StageCheckQuery query;
    @Override
    public String[] getReferenceCode() {
        return new String[]{RefCodeConst.PROJECTPART};
    }

    @Override
    public boolean checkReferenced(String bdCode, String[] keys) throws BusinessException {
        String code = null;
        if(RefCodeConst.PROJECTPART.equals(bdCode)){
            code = BeanHelper.getColName(StageCheckVO.class,StageCheckVO.PK_PROJECTPART);
        } else {
            throw new BusinessException("工序拍照暂未引用该档案!");
        }
        return query.queryRefByIds(code, keys);
    }

}
